import { defineStore } from 'pinia'
import { ref } from 'vue'
import axios from 'axios'
export const useStockStore = defineStore('stock', () => {
    
    const stock_list = ref([])
    const compare_stock_list = ref([])
    async function getStockList() {
        stock_list.value.splice(0, stock_list.value.length);
        // eslint-disable-next-line no-async-promise-executor
        await axios.post("http://127.0.0.1:5000/get_stock_list", {})
            .then(response => {
                for (let i of response.data) {
                        stock_list.value.push(i);
                }
            })
    }
    async function getCompareStockList() {
        compare_stock_list.value.splice(0, compare_stock_list.value.length);
        // eslint-disable-next-line no-async-promise-executor
        await axios.post("http://127.0.0.1:5000/get_compare_stock_list", {})
            .then(response => {
                for (let i of response.data) {
                    compare_stock_list.value.push(i);
                }
            })
    }
    return { getStockList,getCompareStockList, stock_list,compare_stock_list}
}
    , {
        persist: {
            enabled: true
        }
    })
